/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   CSwitchData.h
 * Author: Administrator
 *
 * Created on 2018年11月19日, 下午5:20
 */

#ifndef CSWITCHDATA_H
#    define CSWITCHDATA_H
#include"CSwitchDataStruct.h"
#include"PublicMySql.h"
#include"PublicTool.h"
#include"WorkSnmpApi.h"
#define SWITCH_DATA_FLAG_ARPTABLE       0x0001
#define SWITCH_DATA_FLAG_IPTABLE        0x0002
#define SWITCH_DATA_FLAG_ROUTETABLE     0x0004
#define SWITCH_DATA_FLAG_FDBTABLE       0x0008
#define SWITCH_DATA_FLAG_BASEPORTTABLE   0x0010
#define SWITCH_DATA_FLAG_ALL            0x001F
#define SWITCH_DATA_FLAG_DEBUG       0x0020
#define SWITCH_DATA_FLAG_ALL_DEBUG    0x003F
class CSwitchData {
    std::string          m_ip;//交换机IP
    MAPIPNETTOMEDIATABLE m_ipNetToMediaTable;
    MAPIPADDRTABLE       m_ipAddrTable;
    MAPIPROUTETABLE      m_ipRouteTable;
    MAPFDBTABLE          m_FdbTable;
    MAPUINTLIST          m_BasePortTable;
    
    MAPIPV6NETTOMEDIATABLE m_ipv6NetToMediaTable;
    MAPIPV6ADDRTABLE     m_ipv6AddrTable;
    MAPIPV6ROUTETABLE    m_ipv6RouteTable;
    
    void*                m_ss;
    MYSQL*               m_mysql;
    SNMPSYSPACKET        m_sysinfo;
public:
    CSwitchData(std::string ip);
    virtual ~CSwitchData();
//更新交换机信息
    void UpdateSwitchSysInfo(SNMPSYSPACKET sysinfo);
//更新交换机数据    
    void UpDateSwitchData(int flag=SWITCH_DATA_FLAG_ALL);
//上传到服务器     
    void UpLoadToServer();
private:
    void OpenSession();
    void CloseSession();
    void UpDateipNetToMediaTable();
    void UpDateipv6NetToMediaTable();
    void UpDateipAddrTable();
    void UpDateipv6AddrTable();
    void UpDateipRouteTable();
    void UpDateipv6RouteTable();
    void UpDateFdbTable();
    void UpDateBasePortTable();
    void UpDateFdbTableNormal();
    void UpDateBasePortTableNormal();
    void UpLoadipNetToMediaTable();
    void UpLoadipv6NetToMediaTable();
    void UpLoadipAddrTable();
    void UpLoadipv6AddrTable();
    void UpLoadipRouteTable();
    void UpLoadipv6RouteTable();
    void UpLoadFdbTable();
    void UpLoadBasePortTable();
};

#endif /* CSWITCHDATA_H */

